package dc;

import bbb.sss.Utils;
import distribution.SchemeItem;

public class DCB {

	private SchemeItem red;
	private SchemeItem blue;
	private int multiple;

	public DCB(SchemeItem red, SchemeItem blue, int multiple) {
		super();
		this.red = red;
		this.blue = blue;
		this.multiple = multiple;
	}

	public boolean match(DCB dcb) {
		if (this.red != null && this.blue != null && dcb != null
				&& this.red.matchAll(dcb.getRed())
				&& this.blue.matchAll(dcb.getBlue())) {
			return true;
		}
		return false;
	}

	public SchemeItem getRed() {
		return red;
	}

	public void setRed(SchemeItem red) {
		this.red = red;
	}

	public SchemeItem getBlue() {
		return blue;
	}

	public void setBlue(SchemeItem blue) {
		this.blue = blue;
	}

	public int getMultiple() {
		return multiple;
	}

	public void setMultiple(int multiple) {
		this.multiple = multiple;
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		if(red!=null && red.getCodes()!=null){
			for(int i = 0 ; i < red.getCodes().size() ; i++){
				Integer r = red.getCodes().get(i);
				if(i==0){
					sb.append(Utils.format("%-3d", r));
				}else{
					sb.append(Utils.format("%-3d", r));
				}
			}
		}
		if(blue!=null && blue.getCodes()!=null){
			for(Integer b : blue.getCodes()){
				sb.append(Utils.format("%4d", b));
			}
		}
		return sb.toString();
	}
}
